﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Elements.aspx.cs" Inherits="PmSadis.WebFormsUi.Operator.Elements" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridLookup" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%--<asp:Content ID="elementsHead" ContentPlaceHolderID="head" runat="server">
</asp:Content>--%>
<asp:Content ID="elementsContent" ContentPlaceHolderID="content" runat="server">
<link href="../Content/oper.elements.css" rel="stylesheet" type="text/css" />
    <h2>Элементы</h2>
    <asp:ScriptManager ID="elementsScriptManager" runat="server" />
    <!--elements datasource-->
    <asp:ObjectDataSource ID="dsElements" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Elements" SelectMethod="GetAll" InsertMethod="InsertElement" UpdateMethod="UpdateElement" DeleteMethod="DeleteElement" />
    <!--element types datasource-->
    <asp:ObjectDataSource ID="dsElementTypes" runat="server" TypeName="PmSadis.Providers.AppEnums" SelectMethod="GetAllElementTypes" />
     <!--object types datasource-->
    <asp:ObjectDataSource ID="dsObjectTypes" runat="server" TypeName="PmSadis.Providers.AppEnums" SelectMethod="GetAllObjectTypes" />
    <!--units datasource-->
    <asp:ObjectDataSource ID="dsUnits" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Elements" SelectMethod="Units" />
    <!--element works datasource-->
    <asp:ObjectDataSource ID="dsElementWorks" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Elements" SelectMethod="ElementWorks" InsertMethod="InsertElementWork" DeleteMethod="DeleteElementWork">
        <SelectParameters>
            <asp:SessionParameter Name="elementId" DbType="Int32" SessionField="oper-expanded-element-id" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="worksId" DbType="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <!--works datasource-->
    <asp:ObjectDataSource ID="dsWorks" runat="server" TypeName="PmSadis.WebFormsUi.Operator.Elements" SelectMethod="Works">
        <SelectParameters>
            <asp:SessionParameter Name="elementId" DbType="Int32" SessionField="oper-expanded-element-id" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:UpdatePanel ID="elementsUpdatePanel" runat="server">
        <ContentTemplate>
            <dx:ASPxGridView ID="gvElements" runat="server" DataSourceID="dsElements" KeyFieldName="ElementId" OnRowUpdating="gvElements_RowUpdating" OnRowInserting="gvElements_RowInserting" OnInit="gvElements_Init">
                <SettingsDetail ShowDetailButtons="true" ShowDetailRow="true" />
                <Columns>
                    <dx:GridViewDataColumn FieldName="ElementId" Visible="false" />
                    <dx:GridViewDataDateColumn FieldName="DateCreate" Visible="false" />
                    <dx:GridViewCommandColumn>
                        <NewButton Visible="true" />
                        <EditButton Visible="true" />
                        <DeleteButton Visible="true" />
                    </dx:GridViewCommandColumn>
                    <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование элемента" />
                    <dx:GridViewDataComboBoxColumn FieldName="ElementType" Caption="Тип элемента">
                        <PropertiesComboBox DataSourceID="dsElementTypes" />
                    </dx:GridViewDataComboBoxColumn>
                    <dx:GridViewDataComboBoxColumn FieldName="ObjectType" Caption="Тип объекта">
                        <PropertiesComboBox DataSourceID="dsObjectTypes" />
                    </dx:GridViewDataComboBoxColumn>
                    <dx:GridViewDataComboBoxColumn FieldName="UnitId" Caption="Единица измерения">
                        <EditItemTemplate>
                            <dx:ASPxGridLookup ID="lucUnits" runat="server" DataSourceID="dsUnits" KeyFieldName="UnitId" Width="100%" OnInit="lucUnits_Init" SelectionMode="Single">
                            <GridViewProperties>
                                <Settings ShowFilterRow="true" ShowFilterRowMenu="true" />
                            </GridViewProperties>
                                <Columns>
                                    <dx:GridViewCommandColumn Caption="Выбрать" ShowSelectCheckbox="true" Width="50" />
                                    <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование" />
                                </Columns>
                            </dx:ASPxGridLookup>
                        </EditItemTemplate>
                        <PropertiesComboBox DataSourceID="dsUnits" ValueField="UnitId" ValueType="System.Int32" TextField="Name" />
                    </dx:GridViewDataComboBoxColumn>
                </Columns>
                <Templates>
                    <DetailRow>
                        <dx:ASPxHyperLink ID="hlWorks" runat="server" NavigateUrl="~/operator/works" Target="_blank" Text="Работы" />
                        <dx:ASPxGridView ID="gvElementWorks" runat="server" DataSourceID="dsElementWorks" KeyFieldName="ElementWorkId" OnInit="gvElementWorks_Init" OnBeforePerformDataSelect="gvElementWorks_BeforePerformDataSelect" OnRowInserting="gvElementWorks_RowInserting">
                            <Columns>
                                <dx:GridViewDataDateColumn FieldName="DateCreate" Visible="false" />
                                <dx:GridViewCommandColumn>
                                    <NewButton Visible="true" />
                                    <DeleteButton Visible="true" />
                                </dx:GridViewCommandColumn>
                                <dx:GridViewDataTextColumn FieldName="Code" Caption="Шифр" EditFormSettings-Visible="False" />
                                <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование работы" >
                                    <EditItemTemplate>
                                        <dx:ASPxGridLookup ID="lucWorks" runat="server" DataSourceID="dsWorks" KeyFieldName="WorkId" Width="100%" SelectionMode="Multiple" OnInit="lucWorks_Init" TextFormatString="{1}">
                                            <GridViewProperties>
                                                <Settings ShowFilterRow="true" ShowFilterRowMenu="true" />
                                            </GridViewProperties>
                                            <Columns>
                                                <dx:GridViewCommandColumn Caption="Выбрать" Width="50" ShowSelectCheckbox="true">
                                                    <ClearFilterButton Visible="true" />
                                                </dx:GridViewCommandColumn>
                                                <dx:GridViewDataTextColumn FieldName="Code" Caption="Шифр" />
                                                <dx:GridViewDataTextColumn FieldName="Name" Caption="Наименование работы" />
                                                <dx:GridViewDataComboBoxColumn FieldName="UnitId" Caption="Единица измерения">
                                                    <PropertiesComboBox DataSourceID="dsUnits" ValueField="UnitId" ValueType="System.Int32" TextField="Name" />
                                                </dx:GridViewDataComboBoxColumn>
                                            </Columns>
                                        </dx:ASPxGridLookup>
                                    </EditItemTemplate>
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataComboBoxColumn FieldName="UnitId" Caption="Единица измерения">
                                    <PropertiesComboBox DataSourceID="dsUnits" ValueField="UnitId" ValueType="System.Int32" TextField="Name" />
                                    <EditFormSettings Visible="False" />
                                </dx:GridViewDataComboBoxColumn>
                            </Columns>
                        </dx:ASPxGridView>
                    </DetailRow>
                </Templates>
            </dx:ASPxGridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
